"use strict";
cc._RF.push(module, 'eebafRPVjJFGL49OSzGmbjT', 'disPlayItem');
// scripts/scenes/hall/disPlayItem.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var disItem_1 = require("./disItem");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var disPlayItem = /** @class */ (function (_super) {
    __extends(disPlayItem, _super);
    function disPlayItem() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.lbName = null;
        _this.lbNameBottom = null;
        _this.ndContentList = null;
        _this.pbDisItem = null;
        _this.minMask = null;
        _this.minMask2 = null;
        _this.svList = null;
        _this.showTime = 0.4;
        //
        _this.m_data = null;
        //
        _this.m_minPos = null;
        _this.m_maxPos = null;
        _this.m_minSize = null;
        //
        _this.m_isMin = null;
        //
        _this.isAction = null;
        _this.m_click = false;
        _this.m_isScroll = null;
        return _this;
    }
    disPlayItem.prototype.onLoad = function () {
    };
    disPlayItem.prototype.start = function () {
        this.initView();
        this.svList.node.on('touchstart', this.onTouStart, this);
        this.svList.node.on('touchmove', this.onTouMove, this);
        this.svList.node.on('touchend', this.onTouEnd, this);
        this.svList.node.on('touchcancel', this.onTouEnd, this);
    };
    disPlayItem.prototype.initView = function () {
        var _this = this;
        if (this.m_data == null) {
            console.error('#27 请先初始化数据');
            return;
        }
        //
        for (var _i = 0, _a = this.m_data.disItemIdList; _i < _a.length; _i++) {
            var itemId = _a[_i];
            this.lbNameBottom.string = this.lbName.string = this.m_data.name;
            var node = cc.instantiate(this.pbDisItem);
            this.ndContentList.addChild(node);
            //
            var com = node.getComponent(disItem_1.default);
            com.setId(itemId);
            com.addParentClick(function () {
                _this.m_isScroll = true;
            });
        }
        //
        this.onMin(true);
    };
    disPlayItem.prototype.onTouStart = function (event) {
        this.m_click = true;
    };
    disPlayItem.prototype.onTouMove = function (event) {
        this.m_click = false;
    };
    disPlayItem.prototype.onTouEnd = function (event) {
        if (this.m_click) {
            this.onBtnThis();
        }
    };
    disPlayItem.prototype.onBtnThis = function () {
        if (this.m_isMin) {
            this.onMax();
        }
        else {
            this.onMin();
        }
    };
    disPlayItem.prototype.onScrollView = function (event, target) {
        var _this = this;
        /*
        //
        console.log('输出', this.svList.isScrolling() || this.svList.isAutoScrolling(), this.svList.isScrolling(), this.svList.isAutoScrolling());
        //
        if (this.svList.isScrolling() || this.svList.isAutoScrolling()) {
            return;
        }
        this.onBtnThis();
        return;
        */
        if (!this.m_isMin)
            return;
        //
        var scrollFunction = function () {
            var isScroll = _this.svList.isScrolling();
            if (_this.m_isScroll || isScroll) {
                _this.m_isScroll = isScroll;
                return;
            }
            _this.onBtnThis();
        };
        if (!this.svList.isScrolling()) {
            this.scheduleOnce(scrollFunction);
        }
        else {
            scrollFunction();
        }
    };
    disPlayItem.prototype.onMin = function (isInit) {
        var _this = this;
        if (this.isAction)
            return;
        //
        this.node.zIndex = 0;
        this.isAction = true;
        this.minMask2.active = this.minMask.enabled = true;
        this.m_isMin = true;
        this.lbName.node.active = false;
        this.lbNameBottom.node.active = false;
        this.svList.vertical = false;
        //
        var layout = this.ndContentList.getComponent(cc.Layout);
        //
        if (isInit) {
            this.scheduleOnce(function () {
                _this.svList.node.scaleY = 16 / 9;
            });
            this.lbNameBottom.node.active = true;
            this.node.scaleX = this.m_minSize.width;
            this.node.scaleY = this.m_minSize.height;
            this.node.setPosition(this.m_minPos);
            this.isAction = false;
            layout.paddingTop = 154 + 86.8;
            return;
        }
        //
        cc.Tween.stopAllByTarget(this.svList.node);
        cc.Tween.stopAllByTarget(this.node);
        cc.tween(this.node)
            .parallel(
        // cc.tween().to(this.showTime, {x: this.m_minPos.x, y: this.m_minPos.y}),
        cc.tween(this.node)
            .to(this.showTime * 0.5, { y: this.m_minPos.y + 300 }, { easing: 'quadOut' })
            .to(this.showTime * 0.5, { y: this.m_minPos.y }, { easing: 'quadIn' }), cc.tween(this.node).to(this.showTime, { x: this.m_minPos.x }), cc.tween().to(this.showTime, { scaleX: this.m_minSize.width, scaleY: this.m_minSize.height }))
            .call(function () {
            _this.lbNameBottom.node.active = true;
            _this.ndContentList.y = 517;
            _this.isAction = false;
        })
            .start();
        cc.tween(this.svList.node)
            .to(this.showTime, { scaleY: 16 / 9 })
            .start();
        cc.tween(layout)
            .to(this.showTime, { paddingTop: 154 + 86.8 })
            .start();
    };
    disPlayItem.prototype.onMax = function () {
        var _this = this;
        if (this.isAction)
            return;
        this.isAction = true;
        // this.minMask2.active = this.minMask.enabled = false;
        this.m_isMin = false;
        this.lbName.node.active = false;
        this.lbNameBottom.node.active = false;
        this.svList.vertical = true;
        this.node.zIndex = 1;
        //
        var layout = this.ndContentList.getComponent(cc.Layout);
        //
        cc.Tween.stopAllByTarget(this.node);
        cc.Tween.stopAllByTarget(this.svList.node);
        cc.tween(this.node)
            .parallel(
        // cc.tween().to(this.showTime, {x: this.m_maxPos.x, y: this.m_maxPos.y}),
        cc.tween(this.node)
            .to(this.showTime * 0.5, { y: this.m_maxPos.y + 375 }, { easing: 'quadOut' })
            .to(this.showTime * 0.5, { y: this.m_maxPos.y }, { easing: 'quadIn' }), cc.tween(this.node).to(this.showTime, { x: this.m_maxPos.x }), cc.tween().to(this.showTime, { scale: 1 }))
            .call(function () {
            _this.lbName.node.active = true;
            _this.minMask2.active = _this.minMask.enabled = false;
            _this.isAction = false;
        })
            .start();
        cc.tween(this.svList.node)
            .to(this.showTime, { scaleY: 1 })
            .start();
        cc.tween(layout)
            .to(this.showTime, { paddingTop: 86.8 })
            .start();
    };
    disPlayItem.prototype.setMaxMinParam = function (minPos, maxPos, minSize) {
        this.m_minPos = minPos.clone();
        this.m_maxPos = maxPos.clone();
        this.m_minSize = minSize.clone();
    };
    //
    disPlayItem.prototype.bindData = function (data) {
        this.m_data = data;
    };
    __decorate([
        property(cc.Label)
    ], disPlayItem.prototype, "lbName", void 0);
    __decorate([
        property(cc.Label)
    ], disPlayItem.prototype, "lbNameBottom", void 0);
    __decorate([
        property(cc.Node)
    ], disPlayItem.prototype, "ndContentList", void 0);
    __decorate([
        property(cc.Prefab)
    ], disPlayItem.prototype, "pbDisItem", void 0);
    __decorate([
        property(cc.Mask)
    ], disPlayItem.prototype, "minMask", void 0);
    __decorate([
        property(cc.Node)
    ], disPlayItem.prototype, "minMask2", void 0);
    __decorate([
        property(cc.ScrollView)
    ], disPlayItem.prototype, "svList", void 0);
    __decorate([
        property()
    ], disPlayItem.prototype, "showTime", void 0);
    disPlayItem = __decorate([
        ccclass
    ], disPlayItem);
    return disPlayItem;
}(cc.Component));
exports.default = disPlayItem;

cc._RF.pop();